<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

/* *
 * 前台无需api认证的接口
 * */
Route::group(['namespace' => 'Api'],function ($router){
    $router->post('login', 'UserController@login');
    $router->post('register','UserController@create');
});

/* *
 * 前台需api认证的接口
 * */
Route::group(['namespace' => 'Api', 'middleware' => 'auth:api'],function ($router){
    $router->post('users','UserController@index');
});


/* *
 * 后台无需api认证的接口
 * */
Route::group(['prefix' => 'admin','namespace' => 'Admin'],function ($router){
    $router->post('login', 'AdminController@login');
    $router->post('register','AdminController@store');
});


/* *
 * 后台需api认证的接口
 * */
Route::group(['prefix' => 'admin','namespace' => 'Admin', 'middleware' => 'auth:api'],function ($router){
    $router->post('admins', 'AdminController@index');
    //角色
    $router->post('roles', 'RoleController@index');
    $router->post('role/all', 'RoleController@all');
    $router->post('role/store', 'RoleController@store');
    $router->post('role/update/{id}', 'RoleController@update');
    $router->post('role/delete/{id}', 'RoleController@destroy');
    $router->post('role/{id}', 'RoleController@show');
    $router->post('role/{id}/permissions', 'RoleController@getPermissions');
    $router->post('role/{id}/set-permission', 'RoleController@setPermission');
    //权限
    $router->post('permissions', 'PermissionController@index');
    $router->post('permission/all', 'PermissionController@all');
    $router->post('permission/store', 'PermissionController@store');
    $router->post('permission/update/{id}', 'PermissionController@update');
    $router->post('permission/delete/{id}', 'PermissionController@destroy');
    $router->post('permission/{id}', 'PermissionController@show');
    //菜单
    $router->post('menus', 'MenuController@index');
    $router->post('menu/all', 'MenuController@all');
    $router->post('menu/store', 'MenuController@store');
    $router->post('menu/update/{id}', 'MenuController@update');
    $router->post('menu/delete/{id}', 'MenuController@destroy');
    $router->post('menu/{id}', 'MenuController@show');
    $router->post('menu/{parent_id}/parent-id', 'MenuController@getOneByParentId');
});